//
//  MineWalletRechagePopView.m
//  copyrightTrading
//
//  Created by 郭子一 on 2020/10/6.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "MineWalletRechagePopView.h"

@interface MineWalletRechagePopView ()
@property (nonatomic, strong) InsetsTextField *rechargeTextF;
@end

@implementation MineWalletRechagePopView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
    UIView *bgView = [UIView new];
    bgView.backgroundColor =  RGB_VALUE(0x000000);
    bgView.alpha = 0.4;
    [self addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = UIColor.whiteColor;
    view.layer.cornerRadius = 12;
    view.layer.masksToBounds = YES;
    [self addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.right.offset(-16);
        make.center.offset(0);
        make.height.mas_equalTo(343);
    }];
    
    UILabel *titleLabel = [UILabel new];
    titleLabel.text = @"绑定银行卡";
    titleLabel.font = JSS_MEDIUM_FONT(17);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [view addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(39);
        make.centerX.offset(0);
        make.width.mas_equalTo(135);
        make.height.mas_equalTo(24);
    }];
    
    UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [closeBtn setImage:[UIImage imageNamed:@"popViewClose"] forState:UIControlStateNormal];
    [closeBtn addTarget:self action:@selector(closeBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:closeBtn];
    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-27);
        make.top.offset(24);
        make.width.height.mas_equalTo(24);
    }];
    
    self.rechargeTextF = [[InsetsTextField alloc] init];
    self.rechargeTextF.placeholder = @"输入充值金额";
    self.rechargeTextF.font = JSS_MEDIUM_FONT_2;
    self.rechargeTextF.textColor = RGB_VALUE(0x6F6F6F);
    self.rechargeTextF.layer.masksToBounds = YES;
    self.rechargeTextF.layer.cornerRadius = 12;
    self.rechargeTextF.backgroundColor = RGB_VALUE(0xE6E6E6);
    [view addSubview:self.rechargeTextF];
    [self.rechargeTextF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(17);
        make.top.equalTo(titleLabel.mas_bottom).offset(15);
        make.right.offset(-17);
        make.height.mas_equalTo(51);
    }];
    
    UILabel *wechatLabel = [UILabel new];
    wechatLabel.text = @"微信充值";
    wechatLabel.font = JSS_MEDIUM_FONT(12);
    wechatLabel.textColor = RGB_VALUE(0x6F6F6F);
    [view addSubview:wechatLabel];
    [wechatLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.rechargeTextF.mas_bottom).offset(49);
        make.left.offset(27);
        make.width.mas_equalTo(48);
        make.height.mas_equalTo(17);
    }];
    
    UIButton *wechatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [wechatBtn setImage:[UIImage imageNamed:@"wechat"] forState:UIControlStateNormal];
    [wechatBtn addTarget:self action:@selector(wechatBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:wechatBtn];
    [wechatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(wechatLabel.mas_right).offset(20);
        make.top.equalTo(self.rechargeTextF.mas_bottom).offset(28);
        make.width.height.mas_equalTo(60);
    }];
    
    UIButton *alipayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [alipayBtn setImage:[UIImage imageNamed:@"alipay"] forState:UIControlStateNormal];
    [alipayBtn addTarget:self action:@selector(alipayBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:alipayBtn];
    [alipayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(wechatBtn.mas_top);
        make.right.offset(-27);
        make.width.height.mas_equalTo(60);
    }];
    
    UILabel *alipayLabel = [UILabel new];
    alipayLabel.text = @"支付宝充值";
    alipayLabel.font = JSS_MEDIUM_FONT(12);
    alipayLabel.textColor = RGB_VALUE(0x6F6F6F);
    alipayLabel.textAlignment = NSTextAlignmentRight;
    [view addSubview:alipayLabel];
    [alipayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.rechargeTextF.mas_bottom).offset(49);
        make.right.equalTo(alipayBtn.mas_left).offset(-20);
        make.width.mas_equalTo(68);
        make.height.mas_equalTo(17);
    }];
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginBtn setTitle:@"确定" forState:UIControlStateNormal];
    [loginBtn setTitleColor:RGB_VALUE(0xFFFFFF) forState:UIControlStateNormal];
    [loginBtn.titleLabel setFont:JSS_MEDIUM_FONT_7];
    loginBtn.backgroundColor = RGB_VALUE(0xDC0000);
    loginBtn.layer.masksToBounds = YES;
    loginBtn.layer.cornerRadius = 12;
    [loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:loginBtn];
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(wechatBtn.mas_bottom).offset(26);
        make.right.offset(-81);
        make.left.offset(81);
        make.height.mas_equalTo(51);
    }];
}

- (void)wechatBtnClick
{
    
}

- (void)alipayBtnClick
{
    
}

// 确定
- (void)loginBtnClick
{
    if ([self.delegate respondsToSelector:@selector(RechagePopEnsureBtnClick)]) {
        [self.delegate RechagePopEnsureBtnClick];
    }
    [UIView animateWithDuration:0.1 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

- (void)closeBtnClick
{
    [UIView animateWithDuration:0.1 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}
@end
